package com.yh.supergo.page.controller;

import com.yh.supergo.http.HttpResult;
import com.yh.supergo.page.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

/**
 * @ClassName PageController
 * @Description 商品详情业
 * @Author 0715-YuHao
 * @Date 2020/11/21 10:47
 */
@RestController
public class PageController {

    @Autowired
    private PageService pageService;

    @GetMapping("/html/build/{goodsId}")
    public HttpResult buildHtml(@PathVariable long goodsId) throws IOException {
        return pageService.buildGoodsPage(goodsId);
    }

    @GetMapping("/goods/stock/{goodsId}")
    public Map<Object, Object> getGoodsStock(@PathVariable long goodsId) {
        return pageService.getItemStocks(goodsId);
    }
}
